package zhupf.test.aopDemo;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {

    @Pointcut("execution(* zhupf.test.aopDemo.CalcServiceImpl.*(..))")
    public void apect(){}

    @Before("apect()")
    public void beforeNotify(){
        System.out.println(">>>>>>>>>>>>>>>>>> before notify ");
    }

    @After("apect()")
    public void afterNotify(){
        System.out.println(">>>>>>>>>>>>>>>>>> After notify ");
    }

    @AfterReturning("apect()")
    public void afterReturningNotify(){
        System.out.println(">>>>>>>>>>>>>>>>>> AfterReturning notify ");
    }


    @AfterThrowing("apect()")
    public void afterThrowingNotify(){
        System.out.println(">>>>>>>>>>>>>>>>>> AfterThrowing notify ");
    }

    @Around("apect()")
    public Object aroundNotify(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Object retValue = null;
        System.out.println(">>>>>>> 环绕通知之前");
        retValue = proceedingJoinPoint.proceed();
        System.out.println(">>>>>>> 环绕通知之后");
        return retValue;
    }

}
